#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
ll a[N];
ll sum[N << 2], tag[N << 2];

void pushup(int p) { sum[p] = sum[p << 1] + sum[p << 1 | 1]; }
void build(int p, int l, int r) {
  tag[p] = 0;
  if (l == r) {
    sum[p] = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
void addtag(ll d, int p, int l, int r) {
  tag[p] += d;
  sum[p] += d * (r + 1 - l);
}
void pushdown(int p, int l, int r) {
  if (tag[p]) {
    int mid = (l + r) >> 1;
    addtag(tag[p], p << 1, l, mid);
    addtag(tag[p], p << 1 | 1, mid + 1, r);
    tag[p] = 0;
  }
}
void update(int L, int R, ll d, int p, int l, int r) {
  if (L <= l && R >= r) {
    addtag(d, p, l, r);
    return;
  }
  pushdown(p, l, r);
  int mid = (l + r) >> 1;
  if (L <= mid) update(L, R, d, p << 1, l, mid);
  if (R > mid) update(L, R, d, p << 1 | 1, mid + 1, r);
  pushup(p);
}
ll query(int L, int R, int p, int l, int r) {
  if (L <= l && R >= r) return sum[p];
  pushdown(p, l, r);
  int mid = (l + r) >> 1;
  ll res = 0;
  if (L <= mid) res += query(L, R, p << 1, l, mid);
  if (R > mid) res += query(L, R, p << 1 | 1, mid + 1, r);
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i];
  build(1, 1, n);
  while (m--) {
    int op, x, y;
    ll d;
    cin >> op >> x >> y;
    if (x > y) swap(x, y);
    if (op == 1) {
      cin >> d;
      update(x, y, d, 1, 1, n);
    } else {
      cout << query(x, y, 1, 1, n) << endl;
    }
  }
  return 0;
}